import string

from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.common.by import By


class WebDriverUtils:
    @staticmethod
    def find_elements_with_text(driver: WebDriver, tag_name: string, target_str: string):
        elements = driver.find_elements(By.TAG_NAME, tag_name)
        for element in elements:
            if target_str == element.text:
                return element
        return None

    @staticmethod
    def find_element_by_name(driver: WebDriver, element_name: string):
        return driver.find_element(By.NAME, element_name)

    @staticmethod
    def find_element_by_id(driver: WebDriver, element_id: string):
        return driver.find_element(By.ID, element_id)

    @staticmethod
    def find_element_by_css(driver: WebDriver, css_tag):
        return driver.find_element(By.CSS_SELECTOR, css_tag)

    @staticmethod
    def find_element_by_xpath(driver: WebDriver, xpath_tag):
        return driver.find_element(By.XPATH, xpath_tag)

